{%- macro comment_list(comments,children,pid) %}
    <ul class="{% if children %}ds-children{% else %}ds-comments{% endif %}">
        {% for item in comments.items %}
            <li>
                <div class="comment-self" id="comment-item-{{ item.id }}">
                    <div class="ds-avatar">
                        <a href="{{ url(['for':'user','id':item.uid]) }}">
                            <img alt="角落"
                                 src="{% if item.user.face %}{{ item.user.face }}{% else %}https://avatar.duoshuo.com/avatar-50/214/226670.jpg{% endif %}">
                        </a>
                    </div>
                    <div class="ds-comment-body">
                        <div class="ds-comment-header"><a href="{{ url(['for':'user','id':item.uid]) }}"
                                                          class="ds-user-name">角落</a></div>
                        <div class="comment-body">{{ item.body }}</div>
                        <div class="ds-comment-footer ds-comment-actions"><span title="{{ timeTran(item.created) }}"
                                                                                class="ds-time">{{ timeTran(item.created) }}</span>
                            <div class="comment-action">
                                <a {% if user.isLogin() is false %}ajax-model="/login.html"
                                   {% endif %}pid="{{ item.id }}" nid="{{ item.nid }}" href="#"
                                   class="{% if user.isLogin() %}ds-post-reply{% endif %}"><span
                                            class="ds-icon ds-icon-reply"></span>回复
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                {% set children = commentList(item.nid,item.id) %} {% if children.items %}{{ comment_list(children,true,item.id) }}{% endif %}
            </li>
        {% endfor %}
    </ul>
    {% if comments.total_pages > 1 %} {{ partial("Themes/AdminLTE/templates/paginator-item", ['routerParams':['for':'commentList','nid':item.nid,'pid':pid,'page':1],'data':comments]) }} {% endif %}
{%- endmacro %}

<div class="comment-list">
    {% if data.items %}
        <div class="comment-list-title">
            已有{{ data.total_pages }}个评论
        </div>
        {{ comment_list(data,false,0) }}
    {% else %}
        <p class="no-comment">还没有人评论，快来抢占沙发吧～</p>
    {% endif %}
</div>
